#include <bits/stdc++.h>
#define clr(a) memset(a, 0, sizeof a)
using namespace std;
const int maxn = 50000+10, maxl = 200+10, MN = maxn*maxl;
int n, tr[MN][2], sz, val[MN], ans;

void add(const string &s){
    int p = 0;
    for(char c:s){
        int i = c-'0';
        int &nx = tr[p][i];
        if(!nx) ++sz, clr(tr[sz]), val[sz] = 1, nx = sz;
        else ++val[nx];
        p = nx;
    }
}

void init(){
    sz = 0;
    clr(tr[0]);
}

void dfs(int p, int d){
    ans = max(ans, d*val[p]);
    for (int i = 0; i < 2; ++i) {
        if(tr[p][i])
            dfs(tr[p][i], d+1);
    }
}


int main() {
    int T; cin >> T;
    while (T--){
        init();
        cin >> n;
        for (int i = 0; i < n; ++i) {
            string s; cin >> s;
            add(s);
        }
        ans = 0;
        dfs(0, 0);
        cout << ans << '\n';
    }
    return 0;
}